﻿namespace MetaVideoEditorEvolved.Converter
{
    using System;
    using System.Windows.Data;

    public class BooleanVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool boolValue = (bool)value;

            if (parameter!=null && parameter.ToString() == "revert") {
            	boolValue = !boolValue;
            }
            
            if (boolValue)
            {
                return System.Windows.Visibility.Visible;
            }
            else
            {
                var paramString = parameter as string;

                if (string.IsNullOrEmpty(paramString))
                {
                    return System.Windows.Visibility.Hidden;
                }
                else
                {
                    return System.Windows.Visibility.Collapsed;
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
